/* eslint-disable react/prop-types */
import { Modal } from "antd"

import { IUserInfo } from "@/api/member/types"
import { IMemberParams } from "@/api/risk/types"
import { useLocale } from "@/locales"

import { AccountRemarksModal } from "./AccountRemarksModal"
import { AccountStatusModal } from "./AccountStatusModal"
import { BmhAccUnbindModal } from "./BmhAccUnbindModal"
import { CreditRatingModal } from "./CreditRatingModal"
import { DateOfBirthModal } from "./DateOfBirthModal"
import { GenderModal } from "./GenderModal"
import { LabelMemberModal } from "./LabelMemberModal"
import { LoginPasswordResetModal } from "./LoginPasswordResetModal"
import { MailBoxModal } from "./MailBoxModal"
import { NickNameModal } from "./NickNameModal"
import { PhoneNumberModal } from "./PhoneNumberModal"
import { RebateStatusModal } from "./RebateStatusModal"
import { RiskControlLevelModal } from "./RiskControlLevelModal"
import { UserNameModal } from "./UserNameModal"
import { WithdrawalPasswordResetModal } from "./WithdrawalPasswordResetModal"

interface IMemberDetailModalProps {
	type: string
	handleCancel: () => void
	filterInfo: IMemberParams
	userInfo: IUserInfo
	handleGetUserInfo: () => Promise<void>
}

export const MemberDetailModal: React.FC<IMemberDetailModalProps> = ({
	type,
	handleCancel,
	filterInfo,
	userInfo,
	handleGetUserInfo
}) => {
	const { formatMessage } = useLocale()
	const mess = `member.button_permissions.${type}`
	const title = formatMessage({ id: mess })

	return (
		<Modal footer={null} centered title={title} onCancel={handleCancel} open={type ? true : false}>
			<MemberDetailModalContent
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				type={type}
				userInfo={userInfo}
			/>
		</Modal>
	)
}

export const MemberDetailModalContent: React.FC<IMemberDetailModalProps> = ({
	type,
	handleCancel,
	filterInfo,
	userInfo,
	handleGetUserInfo
}) => {
	if (type === "accountStatus")
		return (
			<AccountStatusModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "riskControlLevel")
		return (
			<RiskControlLevelModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "labelMember")
		return (
			<LabelMemberModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "phoneNumber")
		return (
			<PhoneNumberModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "dateOfBirth")
		return (
			<DateOfBirthModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "nickName")
		return (
			<NickNameModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "userName")
		return (
			<UserNameModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "gender")
		return (
			<GenderModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "mailBox")
		return (
			<MailBoxModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "accountRemarks")
		return (
			<AccountRemarksModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "loginPasswordReset") return <LoginPasswordResetModal data={filterInfo} handleCancel={handleCancel} />
	else if (type === "creditRating")
		return (
			<CreditRatingModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "withdrawalPasswordReset")
		return (
			<WithdrawalPasswordResetModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "rebateStatus")
		return (
			<RebateStatusModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	else if (type === "bmhAccUnbind")
		return (
			<BmhAccUnbindModal
				handleGetUserInfo={handleGetUserInfo}
				filterInfo={filterInfo}
				handleCancel={handleCancel}
				userInfo={userInfo}
			/>
		)
	return <></>
}
